﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using Power.View.Dialog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace Power.ViewModel.Dialog
{
    public class AddSiteViewModel: ViewModelBase
    {
        private AddSite model;
        public AddSiteViewModel(AddSite model)
        {
            this.model = model;
            Close = new RelayCommand(OnClose);
            CloseOK = new RelayCommand(OnCloseOK);
            SetBtnOkEnable(false);
        }

        private void OnCloseOK()
        {
            this.model.DialogResult = true;
            this.model.Close();
        }

        private void OnClose()
        {
            this.model.DialogResult = false;
            this.model.Close();
        }
        public void SetBtnOkEnable(bool status)
        {
            this.model.btnOk.Dispatcher.Invoke(() => {
                this.model.btnOk.IsEnabled = status;
            });
            this.model.btnOkBorder.Dispatcher.Invoke(() => {
                if (status == false)
                {
                    this.model.btnOkBorder.Background = new SolidColorBrush(Color.FromRgb(102, 102, 102));
                }
                else
                {
                    this.model.btnOkBorder.Background = new SolidColorBrush(Color.FromRgb(53, 109, 236));
                }
            });
        }

        #region 
        public RelayCommand Close { get; private set; }

        public RelayCommand CloseOK { get; private set; }
        #endregion
    }
}
